home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6279 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.9 KB  |  79 lines

  1. Newsgroups: comp.lang.c
  2. Path: news.sprintlink.net!news1!news
  3. From: rclark@iquest.net (Robert B. Clark)
  4. Subject: Re: I can't print the date in the format I want.
  5. X-Nntp-Posting-Host: ind-008-237-94.iquest.net
  6. Message-ID: <312de5dc.416111@news.iquest.net>
  7. Sender: news@iquest.net (News Admin)
  8. Organization: IQuest Internet, Inc.
  9. X-Newsreader: Forte Agent .99d/16.182
  10. References: <4g5nbf$8s0@newsbf02.news.aol.com> <3129e355.114134@news.iquest.net> <825035732snz@genesis.demon.co.uk>
  11. Date: Fri, 23 Feb 1996 16:12:38 GMT
  12.  
  13. On Fri, 23 Feb 96 00:35:32 GMT, Lawrence Kirby
  14. <fred@genesis.demon.co.uk> wrote:
  15.  
  16. >In article <3129e355.114134@news.iquest.net>
  17. >           rclark@iquest.net "Robert B. Clark" writes:
  18. >
  19. >>On second thought, I'll comment anyway.  Your function ought to return
  20. >>some sort of value, if for no other reason than to reduce the flamewars
  21. >>people tend to get into over various permutations of the main()
  22. >>declaration:
  23. >>
  24. >>        int main(void)
  25. >
  26. >Good advice but be aware that if the return type of a function
  27. >is unspecified it defaults to int. so ``main() {}'' defines a function that
  28. >takes no arguments and returns int.
  29.  
  30. Thanks for the comments, Lawrence.  I was aware of that, but I tend to
  31. prefer explicit-ness (new word) whenever feasible. :-)
  32.  
  33. >>> debug = strftime(str, 50, "The current date is %y-%m-%d", ptr);
  34. >>
  35. >>"Possible use of 'str' before definition."
  36. >
  37. >Definite misuse of terminology :-)
  38.  
  39. <chuckle> That's what my compiler (TC v3.0) reported.
  40.  
  41. >>> getchar();                           /* OK up to this point? */
  42. >>
  43. >>"Code has no effect."
  44. >>
  45. >>Doesn't do anything but wait for the user to press a key.  If that was
  46. >>your intent, it would be better to express this as
  47. >>
  48. >>        if getchar();
  49. >
  50. >Perhaps you meant:
  51. >
  52. >          if (getchar());
  53.  
  54. Yup.  That's what I get for switching between Pascal and C in the same
  55. day without spending any time in the decontamination chamber.  }:->
  56.  
  57. >However all the if statement seems to do is obfuscate the code.
  58.  
  59. Agreed.  I figured it was there as a sort of pseudo-breakpoint, but I
  60. thought I'd comment on it anyway.  I suggested that if the original
  61. poster wanted to use it thus, he might want to hide it in a moe
  62. appropriately-named macro, such as
  63.  
  64.     #define PAUSE    if (getchar()) {}
  65.  
  66. >The only portable values to return from main() are 0, EXIT_SUCCESS and
  67. >EXIT_FAILURE (the last 2 being defined in stdlib.h). return 0 or return
  68. >EXIT_SUCCESS is probably sensible here.
  69.  
  70. Here is where my DOS/IBM-PC-centric side gets the better of me.  I tend
  71. to write programs that return many "successful" exit codes, with only
  72. one particular value reserved to indicate an error.  For that reason, I
  73. don't use the EXIT_* defines as often as some others might.  Then again,
  74. most of my code is non-portable for other reasons as well. :-)
  75. --
  76. Robert B. Clark <rclark@iquest.net>
  77. "Be wary of strong spirits.  It can make you shoot at tax collectors...
  78. and miss." --RAH
  79.